package com.jiangxfei.mymvp.base;

import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.OnLifecycleEvent;

import com.jiangxfei.mymvp.net.IRepositoryManager;

public class BaseModel implements IModel,LifecycleObserver {
    protected IRepositoryManager mRepositoryManager;

    public BaseModel(IRepositoryManager mRepositoryManager) {
        this.mRepositoryManager = mRepositoryManager;
    }

    @Override
    public void onDestroy() {
        mRepositoryManager=null;
    }
    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    void onDestroy(LifecycleOwner owner) {
        owner.getLifecycle().removeObserver(this);
    }
}
